package com.example.test.advice.第五章_数组和集合.建议73_使用Comparator进行排序;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Client {

    public static void main(String[] args) {
        List<Employee> list = new ArrayList<>(5);
        //一个老板
        list.add(new Employee(1001,"张三",Position.Boss));
        //两个经理
        list.add(new Employee(1006,"赵七",Position.Manager));
        list.add(new Employee(1003,"王五",Position.Manager));
        //两个职员
        list.add(new Employee(1002,"李四",Position.Staff));
        list.add(new Employee(1005,"马六",Position.Staff));
        //按照id排序，也就是按照资历排序
        Collections.sort(list);
        list.forEach(System.out::println);
        System.out.println();
        Collections.sort(list,new PositionComparator());
        list.forEach(System.out::println);
    }
}
